<h2 class="dialog_title"><span>Daftar Perbuatan</span></h2>
<div class="dialog_content" style="padding: 10px 20px; width:700px">
<?php $res = mysql_fetch_assoc(departemen_load($kary_dept))?>
<table width="100%" border="0" cellpadding="5" cellspacing="0">
	<tr>
	  <td align="right">Departemen : </td>
	  <td><strong><?php echo $res['NAMA_DEPARTMENT'] ?></strong></td>
    </tr>
	<tr>
		<td width="100" align="right" >Periode : </td>
		<td><strong><?php echo $month ?> - <?php echo $year ?></strong></td>
	</tr>
</table>
<table style="border:1px solid #457A3F;" width="100%" border="0" cellpadding="5" cellspacing="0">
  <tr class="header">
  	<th align="left"><span class="colorWhite">TGL Lapor</span></th>
    <th align="left"><span class="colorWhite">Jenis</span></th>
    <th align="left"><span class="colorWhite">Bidang</span></th>
    <th align="left"><span class="colorWhite">Tingkat</span></th>
    <th align="left"><span class="colorWhite">Kategori</span></th>
    <th align="right"><span class="colorWhite">Perbuatan ke</span></th>
    <th align="right"><span class="colorWhite">Point</span></th>  
  </tr>
  <tbody id="searchKary-table" style="overflow:scroll; height:200px" >
<?php 
	$result = mysql_query(
		"SELECT a.PERB_TGL, a.KODE_KARYAWAN, b.NAMA_KARYAWAN, a1.DETACHIEV_ID, 
				f.ACHIEV_JENIS, f.ACHIEV_BIDANG, g.DETACHIEV_TINGKAT, g.DETACHIEV_NAMA,
				a1.DEPERB_COUNT, 
					(SELECT NILAI_POINT 
					 FROM nilai as xx 
					 WHERE xx.DETACHIEV_ID = a1.DETACHIEV_ID AND 
					 		a1.DEPERB_COUNT BETWEEN xx.NILAI_MIN AND xx.NILAI_MAX
					) AS POINT
			FROM perbuatan as a, detil_perbuatan as a1, 
				data_karyawan as b, relasi_div_jab_din as c, 
				dep_divisi_jabatan as d, data_department as e,
				prestasipelanggaran as f, detil_prestasi_pelanggaran as g
			WHERE a.PERB_NO = a1.PERB_NO AND
				a1.DEPERB_STATUS='2' AND 
				a.KODE_KARYAWAN = b.KODE_KARYAWAN AND
				b.KODE_KARYAWAN  = c.KODE_KARYAWAN AND
				c.ID_DEP_DIV_JAB = d.ID_DEP_DIV_JAB AND
				d.ID_DEPARTMENT  = e.ID_DEPARTMENT AND
				f.ACHIEV_ID = g.ACHIEV_ID AND 
				g.DETACHIEV_ID = a1.DETACHIEV_ID AND
				e.ID_DEPARTMENT  = '$kary_dept' AND
				year(a.PERB_TGL)='$year' AND month(a.PERB_TGL)='$month'
		ORDER BY NAMA_KARYAWAN, ACHIEV_BIDANG, DEPERB_COUNT");
?>
<?php 
$pointCount = 0;
$nameCount = 0;
$lastName = "";	
?>
<?php while ($row = mysql_fetch_assoc($result)):?>
    <?php if ($lastName=="" || $lastName != $row['NAMA_KARYAWAN']) : ?>
    <?php $nameCount++; ?>
    <?php $lastName=$row['NAMA_KARYAWAN'] ?>
    <tr bgcolor="#CCCCCC">
        <td colspan="7"><?php echo $row['NAMA_KARYAWAN'] ?></td>
    </tr>
    <?php endif;?>
    
    <tr <?php echo tag_zebra($z++)?>>
    	<td><?php echo $row['PERB_TGL']?></td>
        <td><?php echo $row['ACHIEV_JENIS']?></td>
        <td><?php echo $row['ACHIEV_BIDANG']?></td>
        <td><?php echo $row['DETACHIEV_TINGKAT']?></td>
        <td><?php echo $row['DETACHIEV_NAMA']?></td>
        <td align="right"><?php echo $row['DEPERB_COUNT']?></td>
        <td align="right"><?php echo $row['POINT']?></td>
    </tr>
    <?php $pointCount+=$row['POINT']?>
    <?php $devider++; ?>
    
<?php endwhile;?>
  </tbody>
  <tr class="header">
    <th align="right" colspan="6"><span class="colorWhite">Jumlah Point Departemen : </span></th>
    <th align="right"><span class="colorWhite"><?php echo $pointCount?></span></th>  
  </tr>
  <tr class="header">
    <th align="right" colspan="6"><span class="colorWhite">Jumlah Perbuatan : </span></th>
    <th align="right"><span class="colorWhite"><?php echo $devider ?></span></th>  
  </tr>
  <tr class="header">
    <th align="right" colspan="6"><span class="colorWhite">Rata-rata Point Departemen : </span></th>
    <th align="right"><span class="colorWhite"><?php echo $pointCount/$devider ?></span></th>  
  </tr>
</table>
</div>
<div class="dialog_buttons"><input type="button" value="Close" name="close" onclick="FBModal_hide()" /></div>